﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgConsultor.aspx.cs" Inherits="EGuayas.Web.Usuario.pgConsultor" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style>
        /* Styling of global error indicator */
        .form-error-state {
            font-size: 11px;
            padding-left: 20px;
            height: 16px;
            line-height: 18px;
            background: no-repeat 0 0;
            cursor: default;
        }

        .form-error-state-invalid {
            color: #C30;
            background-image: url(../../../../icons/exclamation-png/ext.axd);
        }

        .form-error-state-valid {
            color: #090;
            background-image: url(../../../../icons/accept-png/ext.axd);
        }

        /* Error details tooltip */
        .errors-tip .error {
            font-style: italic;
        }
    </style>
    <!-- Load Ext JS -->
    <script src="../Resources/js/Global.js"></script>
    <script src="../Resources/js/Usuario.js"></script>
</head>
<body>
    <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
            <Items>
                <%-- Hidden almacena IdPageSession  --%>
                <ext:Hidden Text="" ID="hddIdPageSession" runat="server"></ext:Hidden>
                <%-- Hidden almacena Id Usuario --%>
                <ext:Hidden Text="" ID="hddIdPersonaTmp" runat="server"></ext:Hidden>
                <%-- Hidden add  
                <ext:Hidden Text="" ID="hddCountNumDoc" runat="server"></ext:Hidden>
                <ext:Hidden Text="" ID="hddCountNumLoadDoc" runat="server"></ext:Hidden>
                <ext:Hidden Text="" ID="hddnDocUpRef" runat="server"></ext:Hidden>
                --%>
                <ext:FormPanel ID="frmGeneral" runat="server"
                    DefaultAnchor="100%" Layout="AnchorLayout" AutoScroll="true" ButtonAlign="Center"
                    Region="Center">
                    <FieldDefaults LabelAlign="Right" LabelWidth="90" MsgTarget="Qtip" />
                    <Items>
                        <%-- 
                    <ext:TabPanel ID="TabPanel1" 
                    runat="server" 
                    Region="Center"
                    ActiveTabIndex="0"                    
                    MarginSpec="5 5 5 0">
                    <Items>
                        --%>
                        <ext:FormPanel ID="frmPromotor"
                            runat="server"
                            Frame="true"
                            BodyPadding="5"
                            Border="false"
                            Title="Datos Promotor"
                            DefaultAnchor="100%"
                            Icon="Vcard"
                            Collapsible="true">
                            <%--  <FieldDefaults LabelAlign="Left" MsgTarget="None" InvalidCls="" />    --%>

                            <Items>
                                <ext:FieldSet ID="FieldSet1"
                                    Flex="1"
                                    runat="server"
                                    BodyPadding="5"
                                    Layout="AnchorLayout"
                                    DefaultAnchor="100%">
                                    <Items>
                                        <ext:Container ID="Container4"
                                            runat="server"
                                            Layout="HBoxLayout"
                                            MarginSpec="5 0 5 0">
                                            <Items>
                                                <ext:ComboBox ID="cbxTipoPersona"
                                                    FieldLabel="Persona"
                                                    AllowBlank="false"
                                                    runat="server"
                                                    Anchor="none">
                                                    <Items>
                                                        <ext:ListItem Text="Persona Juridica" Value="PJ"></ext:ListItem>
                                                        <ext:ListItem Text="Persona Natural" Value="PN"></ext:ListItem>
                                                    </Items>
                                                    <Listeners>
                                                        <BeforeSelect Handler="return pgFn.BeforeSelectCbbPersona(item,record,index);"></BeforeSelect>
                                                        <Select Handler="pgFn.updateSelectRadioButton(item.getValue(),#{frmPromotor},#{ctTipoPersona})"></Select>
                                                    </Listeners>
                                                </ext:ComboBox>
                                                 <ext:TextField Name="CodigoMae" runat="server" ID="txtCodigoMae" FieldLabel="Código:" AllowBlank="true"></ext:TextField>
                                            </Items>
                                        </ext:Container>
                                        <ext:Container ID="ctTipoPersona"
                                            Hidden="true"
                                            runat="server">
                                            <Items>

                                                <ext:Container ID="Container2"
                                                    runat="server"
                                                    Layout="HBoxLayout"
                                                    MarginSpec="0 0 5 0">
                                                    <Items>
                                                        <ext:FieldContainer ID="FieldContainer3"
                                                            runat="server"
                                                            Flex="1"
                                                            FieldLabel="Ruc"
                                                            Layout="HBoxLayout"
                                                            CombineErrors="true">
                                                            <FieldDefaults />
                                                            <Items>
                                                                <ext:TextField ID="txtRuc"
                                                                    runat="server"
                                                                    Flex="2"
                                                                    Name="Ruc"
                                                                    ItemID="per_nombre"
                                                                    EmptyText="xxxxxxxxxxxxx"
                                                                    MaskRe="[\d]"
                                                                    MinLength="13"
                                                                    MaxLength="13"
                                                                    AllowBlank="true">
                                                                    <AfterLabelTextTpl runat="server">
                                                                        <Html>
                                                                            <span style="color: red; font-weight: bold" data-qtip="Required">*</span>
                                                                        </Html>
                                                                    </AfterLabelTextTpl>
                                                                </ext:TextField>
                                                                <ext:TextField ID="txtRazonS"
                                                                    runat="server"
                                                                    Flex="2"
                                                                    Name="Razonsocial"
                                                                    FieldLabel="Razón Social"
                                                                    AllowBlank="true"
                                                                    Margins="0 0 0 5">
                                                                    <AfterLabelTextTpl runat="server">
                                                                        <Html>
                                                                            <span style="color: red; font-weight: bold" data-qtip="Required">*</span>
                                                                        </Html>
                                                                    </AfterLabelTextTpl>
                                                                </ext:TextField>
                                                                <ext:ComboBox ID="cbbTipoOrga" runat="server" FieldLabel="Organización"
                                                                    Flex="2" Name="Organizacion" AllowBlank="true"
                                                                    ValueField="Id" DisplayField="Nombre">
                                                                    <Store>
                                                                        <ext:Store runat="server" ID="stoTipoOrganizacion">
                                                                            <Model>
                                                                                <ext:Model ID="Model4" runat="server" IDProperty="Id">
                                                                                    <Fields>
                                                                                        <ext:ModelField Name="Id"></ext:ModelField>
                                                                                        <ext:ModelField Name="Nombre"></ext:ModelField>
                                                                                    </Fields>
                                                                                </ext:Model>
                                                                            </Model>
                                                                        </ext:Store>
                                                                    </Store>
                                                                    <Triggers>
                                                                        <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                                    </Triggers>
                                                                    <Listeners>
                                                                        <Select Handler="this.getTrigger(0).show();" />
                                                                        <BeforeQuery Handler="this.getTrigger(0)[this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                                        <TriggerClick Handler="if (index == 0) { 
                                                                               this.clearValue(); 
                                                                               this.getTrigger(0).hide();
                                                                           }" />
                                                                    </Listeners>
                                                                </ext:ComboBox>
                                                            </Items>
                                                        </ext:FieldContainer>

                                                    </Items>
                                                </ext:Container>
                                            </Items>
                                        </ext:Container>
                                    </Items>
                                </ext:FieldSet>
                            </Items>
                        </ext:FormPanel>
                        <ext:UserControlLoader ID="uc_per_U004" UserControlID="wuc_persona" runat="server" Path="~/Usuario/wucPersona.ascx" OnComponentAdded="OnPersonaAdded"/>
                       
                        <ext:FormPanel
                            ID="frmInfoAdd"
                            runat="server"
                            BodyPadding="5"
                            Title="Información Adiconal"
                            Icon="LayoutEdit"
                            Layout="AnchorLayout"
                            DefaultAnchor="100%"
                            Frame="true"
                            Collapsible="true">
                            <Items>
                                <ext:Container ID="Container3" runat="server"
                                    Layout="HBoxLayout"
                                    MarginSpec="0 0 5 0">
                                    <Items>
                                        <ext:TextField ID="txtFono"
                                            runat="server"
                                            Name="Telefono"
                                            AllowBlank="true"
                                            FieldLabel="Telefóno"
                                            LabelWidth="100"
                                            Flex="2"
                                            EmptyText="xxxxxxxxxx"
                                            MaskRe="[\d\-]"
                                            Regex="^\d{10}$"
                                            RegexText="Formato xxxxxxxxxx">
                                        </ext:TextField>

                                        <ext:TextField ID="txtCel"
                                            runat="server"
                                            Name="TelefonoCelular"
                                            AllowBlank="false"
                                            FieldLabel="Celular"
                                            LabelWidth="100"
                                            Flex="2"
                                            EmptyText="xxxxxxxxxx"
                                            MaskRe="[\d\-]"
                                            Regex="^\d{10}$"
                                            RegexText="Formato xxxxxxxxxx">
                                        </ext:TextField>
                                        <ext:TextField ID="txtFax"
                                            runat="server"
                                            AllowBlank="true"
                                            FieldLabel="Fax"
                                            Name="Fax"
                                            LabelWidth="100"
                                            Flex="2"
                                            EmptyText="xxxxxxxxxx"
                                            MaskRe="[\d\-]"
                                            Regex="^\d{10}$"
                                            RegexText="Formato xxxxxxxxxx">
                                        </ext:TextField>
                                    </Items>
                                </ext:Container>



                            </Items>
                        </ext:FormPanel>
                        <ext:UserControlLoader ID="uc_cuenta_U002"  UserControlID="wuc_cuenta" runat="server" Path="~/Usuario/wucCuenta.ascx" OnComponentAdded="OnCuentaAdded"/>
                         <%-- <ext:Hidden Text="" ID="hddEvento" runat="server"  Name="Evento" />       --%>  
                        <ext:UserControlLoader ID="uc_doc_U001" UserControlID="wuc_documentos" runat="server" Path="~/Usuario/wucDocUser.ascx" OnComponentAdded="OnDocUserAdded"/>
                        <%--                   
                   </Items>
                </ext:TabPanel> 
                        --%>
                    </Items>
                    <DockedItems>
                        <ext:Container ID="Container1"
                            runat="server"
                            Dock="Bottom"
                            PaddingSpec="10 10 10">
                            <LayoutConfig>
                                <ext:HBoxLayoutConfig Align="Middle" />
                            </LayoutConfig>
                            <Items>
                                <ext:Component ID="Component1"
                                    runat="server"
                                    ItemID="formErrorState"
                                    BaseCls="form-error-state"
                                    DefaultAnchor="100%"
                                    Flex="1">
                                    <Bin>
                                        <ext:XTemplate ID="XTemplate1" runat="server">
                                            <Html>
                                                <ul>
                                            <tpl for=".">
                                                <li>
                                                    <span class="field-name">{name}</span> : <span class="error">{error}</span>
                                                </li>
                                            </tpl>
                                        </ul>
                                            </Html>
                                        </ext:XTemplate>
                                    </Bin>
                                    <ToolTips>
                                        <ext:ToolTip ID="ToolTip1"
                                            runat="server"
                                            Title="Error Detalles:"
                                            AutoHide="false"
                                            Anchor="top"
                                            MinWidth="450"
                                            MinHeight="80"
                                            MouseOffset="-11,-2"
                                            Closable="true"
                                            Disabled="true"
                                            DefaultAnchor="100%"
                                            ConstrainPosition="true"
                                            Cls="errors-tip" />
                                    </ToolTips>
                                </ext:Component>
                                <ext:Button ID="btnSaveForm"
                                    runat="server"
                                    Text="Aceptar"
                                    Width="140">
                                    <DirectEvents>
                                        <%-- No invocar  pgFn.ViewGrid ya que se lo invoca en el code  --%>
                                        <Click
                                            OnEvent="SaveClick"
                                            Before="return pgFn.validFormGeneral(this);">
                                            <ExtraParams>
                                               <%--  <ext:Parameter Name="ifDelegado" Value="#{chkDelegado}.getValue()" Mode="Raw" /> --%>
                                                <ext:Parameter Name="prmValues" Value="Ext.encode(this.up('form').getForm().getValues())" Mode="Raw" />
                                            </ExtraParams>
                                            <EventMask ShowMask="True"></EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="btnModificar"
                                    runat="server"
                                    Text="Aceptar"
                                    Width="140">
                                    <DirectEvents>
                                        <Click
                                            OnEvent="ModificarClick"
                                            Before="return pgFn.validFormGeneral(this);">
                                            <ExtraParams>
                                                <ext:Parameter Name="prmValues" Value="Ext.encode(this.up('form').getForm().getValues())" Mode="Raw" />
                                                <ext:Parameter Name="ifDelegado" Value="#{chkDelegado}.getValue()" Mode="Raw" />
                                            </ExtraParams>
                                            <EventMask ShowMask="True"></EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="btnEliminar"
                                    runat="server"
                                    Text="Aceptar"
                                    Width="140">
                                    <DirectEvents>
                                        <Click
                                            OnEvent="EliminarClick">
                                            <ExtraParams>
                                                <ext:Parameter Name="prmValues" Value="Ext.encode(App.frmGeneral.getForm().getValues())" Mode="Raw" />
                                            </ExtraParams>
                                            <Confirmation ConfirmRequest="true" Title="Confirmar" Message="Desea eliminar usuario?" />
                                            <EventMask ShowMask="True"></EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Container>
                    </DockedItems>
                    <Buttons>
                    </Buttons>
                </ext:FormPanel>

            </Items>
        </ext:Viewport>
    </form>
    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var pgFn    = new Object();               
            //Invocar desde el server vizualizar panel delegado y selecionar [checkbox delegado]
           /*
            pgFn.OnlyShowPanelDelegado = function(_checked){
                try{
                    var myCheckBox = App.chkDelegado;
                    var cmpTmp     = Ext.getCmp('wuc_delegado' + '_' + 'frmPersona');
                    AppUser.Global.SetAllowBlank(cmpTmp,!_checked);
                    if(_checked)
                        cmpTmp.show();
                    else
                        cmpTmp.hide();
                    //App.chkDelegado.checked =_checked;
                    myCheckBox.suspendEvents(false); // Stop all events. 
                    //Be careful with it. Dont forget resume events!
                    myCheckBox.setValue(_checked); // invert value
                    myCheckBox.resumeEvents(); // resume events
          
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.OnlyShowPanelDelegado: " + jsbug)
                }
            };
           
            //Evento seleccion de checkbox delegado 
            pgFn.SelectCheckbox_ViewDelegado = function(cb, checked){
                try
                {
                    var cmpEvent=Ext.getCmp('wuc_documentos_001' + '_' + 'hddEvento');
                    if (cmpEvent.getValue()=="NUEVO")
                    {
                        var cmpTmp=Ext.getCmp('wuc_delegado' + '_' + 'frmPersona');
                        AppUser.Global.SetAllowBlank(cmpTmp,!checked);
                        
                        App.direct.wucDocUser.BindDataDocDelegado(checked,{
                            success: function (result) {
                                if(checked)
                                    cmpTmp.show();
                                else
                                    cmpTmp.hide(); 
                            },
                            eventMask: {
                                showMask: true,
                                minDelay: 500
                            }
                        });
                       
                    }
                    else
                    { 
                        var cmpTmp=Ext.getCmp('wuc_delegado' + '_' + 'frmPersona');
                        AppUser.Global.SetAllowBlank(cmpTmp,!checked);
                        if(checked)
                            cmpTmp.show();
                        else
                            cmpTmp.hide(); 
                
                    }
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.SelectCheckbox_ViewDelegado: " + jsbug)
                }
            };
            */
            //Cerrar ventana promotor cuando la interfaz se vizualiza como ventana popup
            pgFn.CloseWinNew = function(){
                try{
                    window.parent.App.CloseWinUserNewPromotor();
                }catch(jsbug){
                    AppGlobalJs.showBug(" pgFn.CloseWinNew: " + jsbug)
                }
            };
            //Setear los datos de persona
            pgFn.setDatosWucPersona = function(sIdent, sNombr, sApellid){
                try{
                    var cmpTmp=Ext.getCmp('wuc_persona' + '_' + 'txtIdentifi');
                    cmpTmp.setValue(sIdent);
                    cmpTmp=Ext.getCmp('wuc_persona' + '_' + 'txtNombre');
                    cmpTmp.setValue(sNombr);
                    cmpTmp=Ext.getCmp('wuc_persona' + '_' + 'txtApellido');
                    cmpTmp.setValue(sApellid);
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.setDatosWucPersona: " + jsbug)
                }
            };
            //Validacion de formulario
            pgFn.validFormGeneral = function(me){
                try{
                    var frm = me.up('form');
                    //AppGlobalJs.showBug(Ext.encode(frm.getForm().getValues()));
                    var done=pgFn.updateErrorState(frm);
                    return (done); 
                }catch(jsbug){
                    AppGlobalJs.showBug("  pgFn.updateErrorState: " + jsbug)
                }
            };
            //Vizualizar icono de validacion
            pgFn.UpdatePanelError = function(){
                try{
                    var me = Ext.getCmp('Component1'),
                    baseCls = me.baseCls;
                    me.addCls(baseCls + '-valid');
                    me.removeCls(baseCls + '-invalid');
                    me.update("Formulario valido");
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.UpdatePanelError: " + jsbug)
                }
            };
            //Actualizar icono de error al validar
            pgFn.updateErrorState = function(form,viewTip){
                try{
                    var  errorCmp, errors;
                    //if (me.hasBeenDirty || me.getForm().isDirty()) { //prevents showing global error when form first loads
                    errorCmp = form.down('#formErrorState');
                    errors= AppUser.Global.GetListErrors(form);
                    //var flag=form.getForm().isValid();
                    //if (flag==false & errors.length==0)
                    //    errors.push({ name: 'Error', error: 'Usuario Invalido' });
                    //Validar Identificacion
                    var errorRuc = AppUser.Global.ValidarDocumento(Ext.getCmp('wuc_persona' + '_' + 'txtIdentifi').getValue());
                    if (errorRuc!="")
                        errors.push({ name: 'Identificación', error: errorRuc});
                    //Validar Ruc
                    errorRuc = AppUser.Global.ValidarDocumento(Ext.getCmp('txtRuc').getValue());
                    if (errorRuc!="")
                        errors.push({ name: 'Ruc', error: errorRuc});
                    if (typeof viewTip=="undefined")
                        viewTip="S";
                    AppUser.Global.SetErrors(errorCmp, errors,viewTip);
                    //me.hasBeenDirty = true;
                    //}
                    flag=(errors.length==0);//Agregada la validacion de (+)ruc,cedula
                    //flag=
                    form.getForm().isValid();
                    if (flag == false)
                    {
                        var infoAdd = " <ol>";
                        var infodeta = "";
                        /*
                        <ol> 
                             <li>Uno</li> 
                             <li>Dos</li> 
                             <li>Tres</li> 
                        </ol> 
                        */
                        Ext.Array.forEach(errors, function (bug) {
                            infodeta = bug.name+":"+bug.error;                           
                            infoAdd += "<li>" + infodeta + "</li>";
                        });
                        infoAdd += "</ol>";

                        Ext.Msg.show({
                            title: '',
                            maxWidth : 300,
                            width: 300,
                            msg: AppLabelGlobalJs.pg_datos_obli+ infoAdd,
                            buttons: Ext.Msg.ERROR,
                            animEl: 'elId'
                        });
                    }

                    return(flag);
                }catch(jsbug){
                    AppGlobalJs.showBug("  pgFn.updateErrorState: " + jsbug)
                }
                
            };
            //Evento [radio] tipo de persona
            pgFn.updateSelectRadioButton = function(valSelect,form,content){
                try{
                    //var valSelect =item.getValue();
                    var me = form,fields;
                    var ifEnable=(valSelect=="PN");
                    var cmpDatosPersona = Ext.getCmp('wuc_persona_frmPersona');
                    var titulo = !ifEnable ? 'Datos generales de persona jurídica' : 'Datos generales de persona natural';
                    cmpDatosPersona.setTitle(titulo);
                    var cmpEvent=Ext.getCmp('wuc_documentos' + '_' + 'hddEvento');
                    if (cmpEvent.getValue()!="LECTURA")
                    {
                        fields = me.getForm().getFields();              
                        fields.each(function (field) {
                            if( field.id!="cbxTipoPersona")
                            {
                                field.allowBlank=ifEnable;
                            }
                        });
                        pgFn.updateErrorState(#{frmGeneral},"N");
                        if (ifEnable)
                        {
                            App.direct.wucDocUser.BindDataDocumentos("S",{
                                success: function (result) {
                                    content.hide();
                                },
                                eventMask: {
                                    showMask: true,
                                    minDelay: 500
                                }
                            });
                           
                        }
                        else
                        {  
                            App.direct.wucDocUser.BindDataDocumentos("N",{
                                success: function (result) {
                                    content.show();
                                },
                                eventMask: {
                                    showMask: true,
                                    minDelay: 500
                                }
                            });
                            
                        }
                    }
                    else
                    {
                        if (ifEnable)
                        {
                           
                            content.hide();
                        }
                        else
                        {  
                           
                            content.show();
                        }
                    
                    }
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.updateSelectRadioButton: " + jsbug)
                }
                
            };           
            //Ocutar grid de documentos y colocar readonly elementos de formulario
            pgFn.SetReadOnlyOffLine = function(_title,_msg)
            {
                try{
                    pgFn.SetReadOnly(true);
                    var cmpTmp=Ext.getCmp('wuc_documentos' + '_' + 'frmSettings');
                    if (cmpTmp)
                        cmpTmp.hide(); 
                    Ext.Msg.show({ 
                        title   : _title, 
                        msg     : _msg, 
                        minWidth: 200, 
                        modal   : true, 
                        icon    : Ext.Msg.INFO, 
                        buttons : Ext.Msg.OK 
                    });
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.SetReadOnlyOffLine: " + jsbug)
                }
            };            
            //Colocar readonly elementos de formulario
            pgFn.SetReadOnly = function(readOnly)
            {
                try{
                    var fields = #{frmGeneral}.getForm().getFields();
                    fields.each(function (field) {
                        if (field.rendered) {
                            field.el.dom.setAttribute("readOnly",readOnly);
                        }
                        field.setReadOnly(readOnly);
                    });
                }catch(jsbug){
                    AppGlobalJs.showBug(" pgFn.SetReadOnly: " + jsbug)
                }
            
            };
            //Selecionar [cbox] persona, actualizar panel y colocar readonly elementos del formulario
            pgFn.UpdatePanelSelectCbbPersona = function(val,readOnly)
            {
                try{
                    App.cbxTipoPersona.select(val, true);
                    pgFn.updateSelectRadioButton(val,#{frmPromotor},#{ctTipoPersona});
                    if (readOnly==true)
                    {
                        pgFn.SetReadOnly(readOnly);
                    }
                }catch(jsbug){
                    AppGlobalJs.showBug(" pgFn.UpdatePanelSelectCbbPersona: " + jsbug)
                }

            };
            //Evento seleccion [cbx] tipo persona
            pgFn.BeforeSelectCbbPersona = function(item,record,index)
            {
                try{
                    var itemCmp  =(item!=null)?item:App.cbxTipoPersona;
                    var cmpEvent=Ext.getCmp('wuc_documentos' + '_' + 'hddEvento');
                    if (cmpEvent.getValue()!="LECTURA")
                    {
                        cmpEvent=Ext.getCmp('wuc_documentos' + '_' + 'numDoc');
                        var  flag   =(cmpEvent.getValue()!=0);   
                        var bReturn =false;
                        var val=record.raw[0];
                        if(flag==true)
                        {
                      
                            Ext.Msg.confirm('Modificar selección', 'Al modificar selección los archivos agregados seran eliminados?', function (btn) {
                                if (btn == 'yes') {                       
                                    App.direct.wucDocUser.DeleteFiles({
                                        success: function (result) {
                                            bReturn =true;
                                            itemCmp.lockedBeforeSelect = false;                              
                                            pgFn.UpdatePanelSelectCbbPersona(val,false);
                                        },
                                        eventMask: {
                                            showMask: true,
                                            minDelay: 500
                                        }
                                    });
                                
                                
                                }else
                                {
                                    bReturn =false;
                                    itemCmp.lockedBeforeSelect = true;
                                }                      
                            } );    
                  
                        }
                        else
                        {
                            bReturn =true;
                        }

               
                        return bReturn;
                    }
                    else
                    {
                        itemCmp.lockedBeforeSelect = true;
                    }
                    return false;
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.BeforeSelectCbbPersona: " + jsbug)
                }
            };
            //Vizualizar grid principal, de la ventana que invoca
            pgFn.ViewGrid = function(msg)
            {
                try{
                    window.parent.App.ViewGrid(msg);//Invoca metodo de frame
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.ViewGrid: " + jsbug)
                }
            };
            pgFn._collapsePanels = function(pnlForm,val)
            {
                try
                {
                    if(pnlForm )
                    {
                        if (val==true)
                            pnlForm.collapse();
                        else
                            pnlForm.expand();
                    }
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn._collapsePanels: " + jsbug)
                }
            }
            //Colapsar panels para vizualizar la información
            pgFn.CollapsePanels = function(val)
            {
                try
                {
                    var pnlForm = Ext.getCmp('wuc_delegado' + '_' + 'frmPersona');
                    pgFn._collapsePanels(pnlForm,val);
                    pnlForm = Ext.getCmp('wuc_persona' + '_' + 'frmPersona');
                    pgFn._collapsePanels(pnlForm,val);
                    pnlForm = Ext.getCmp('wuc_cuenta' + '_' + 'frmCuenta');
                    pgFn._collapsePanels(pnlForm,val);
                    pgFn._collapsePanels( #{frmInfoAdd},val);
                    pgFn._collapsePanels( #{frmInfoAdd},val);
                 
                }catch(jsbug){
                    AppGlobalJs.showBug("pgFn.CollapsePanels: " + jsbug)
                }
            };
       </script>
    </ext:XScript>
</body>
</html>
